package com.quasar.hpatient.view.adapter.render;

import android.content.Context;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import com.ada.adapter.RenderBuiler;
import com.quasar.hpatient.R;
import com.quasar.hpatient.model.medicalmodel.PrescriptionDayData;
import com.quasar.hpatient.utils.Spanny;

/**
 * 药品列表
 * Created by Administrator on 2017/5/25 0025.
 */

public class DrugsListRender extends RenderBuiler<PrescriptionDayData.ListBean.PerscriptDetailListBean.PrescriptionDoseDetailBean> implements View.OnClickListener {

    TextView tv_title;
    private String doseName;

    public String getDoseName() {
        return doseName;
    }

    public void setDoseName(String doseName) {
        this.doseName = doseName;
    }

    public void setSpecification(String specification) {
        Specification = specification;
    }

    //药品规格
    public String Specification;

    public DrugsListRender(Context context) {
        super(context);
    }

    @Override
    public void onClick(View v) {

    }

    private int color(int value){
        return getContext().getResources().getColor(value);
    }

    @Override
    public void render() {

        String  geshu =null;//服药个数
        String shijian=null;

        if(getContent().getUseTime()!=null){
            shijian=getContent().getUseTime().substring(10,16);
        }

        if(getContent().getUseCount()!=0){
            geshu=getContent().getUseCount()+"";
        }

        Spanny spanny=new Spanny();
        spanny.append("第"+getContent().getDetailId()+"次\t"+shijian+"服用",new ForegroundColorSpan(color(R.color.textcolor)));
        spanny.append(geshu+"×"+getDoseName(),new ForegroundColorSpan(color(R.color.textcolor)));
        tv_title.setText(spanny);
    }

    @Override
    protected void setUpView(View view) {
        tv_title= (TextView) view.findViewById(R.id.tv_title);
    }

    @Override
    protected void hookListeners(View view) {

    }

    @Override
    protected int getlayoutid() {
        return R.layout.medication_list_item_layout;
    }
}
